package com.wsl.controller.type;

import com.wsl.message.MessageUtil;
import com.wsl.message.StatusCode;
import com.wsl.service.type.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: wsl
 * @Date: 2022/2/17 15:48
 */

@RequestMapping("/admin/type")
@RestController
public class TypeController extends MessageUtil {

    @Autowired
    TypeService typeService;


    @RequestMapping(value = "/getAllType", method = RequestMethod.GET)
    public String getAllType() {
        return write(StatusCode.SUCCESS, typeService.getTypeAll());
    }


    @RequestMapping(value = "/saveType",method = RequestMethod.POST)
    public String saveType(
            @RequestParam(value = "typeName", required = true) String typeName) {

        try {
            int i = typeService.setTag(typeName);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return write(StatusCode.SUCCESS);

    }

    @RequestMapping(value = "/delType",method = RequestMethod.POST)
    public String delType(@RequestParam(value = "typeName",required = true)String typeName){
        try {
            typeService.delTag(typeName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return write(StatusCode.SUCCESS);
    }

}